#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int judge(char arr1[], char arr2[])
{
	int len = strlen(arr1);
	int i, j;
	char tmp;
	for (i = 0; i < len-1; i++)
	{
		tmp = arr2[0];
		for (j = 0; j < len-1; j++)
		{
			arr2[j] = arr2[j + 1];
		}
		arr2[j] = tmp;
		if (strcmp(arr1, arr2) == 0)
			return 1;
	}
	return 0;
}
int main()
{
	char arr1[10] = { 0 };
	char arr2[10] = { 0 };
	gets(arr1);
	gets(arr2);
	printf("%d",judge(arr1, arr2));
	return 0;
}